package com.wh.accesscontrol.config;

import com.wh.accesscontrol.util.RedisUtil;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.context.support.WebApplicationContextUtils;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class WebConfigurer extends WebMvcConfigurationSupport {
/**
 * <h3>accesscontrol</h3>
 * <p>拦截器</p>
 * @author : WH
 * @date : 2020-03-03 15:07
 **/

//@Autowired
//    private LoginInterceptor loginInterceptor;
    @Bean
    LoginInterceptor localInterceptor() {
        return new LoginInterceptor();
    }




    public void addInterceptors(InterceptorRegistry  registry) {
        registry.addInterceptor(new LoginInterceptor()).addPathPatterns("/**").excludePathPatterns("/login");
    };

    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
        super.addResourceHandlers(registry);
    }




}
